﻿package com.xuanque.mahjongDice.util 
{
	
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;
	
	import datas.Player;
	import flash.utils.getDefinitionByName;
	import utils.HallConfig;
	
	/**
	 * ...
	 * @author DefaultUser (Tools -> Custom Arguments...)
	 */
	public class LoaderImg 
	{
		private static var Instance:LoaderImg = new LoaderImg();
		
		
		public function LoaderImg() 
		{
			if(Instance!=null){
				throw new Error("单件")
			}
        }
		
		/*
		 * 单件类的实例 
		*/
		public static function getInstance():LoaderImg{
			return Instance;
		}
		
		
		public function setStaticObjectNull():void{
		    Instance = null;
		}
		
		
		/*
		 * 为某一影片剪辑添加图片 
		*/
		public function loadPhoto(_mc:DisplayObjectContainer, player:*) 
		{
			
			var sex:String = player.getSex()==0?"Man0":"Woman1";
		    
		    if (parseInt(player.getPhoto()) > 20 || parseInt(player.getPhoto()) == 0) {
			    sex = "Animal";
			}
			var photo:String = "com.photo." + sex + "" + player.getPhoto();
			var PhotoImg:Class = HallConfig.getIntance().getApplication().getDefinition(photo) as Class;
			
			_mc.addChild(new PhotoImg());
			
        }
		
		/*
        private function copleateHandler(event:Event) : void
        {
            var _loader:DisplayObject = event.target.content as DisplayObject;
            _loader.width = 32;
            _loader.height = 32;
			
			//_loader.x = Math.random() * 50;
			
        }
		
		*/
	}
	
}